package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * @author xingjishuai
 * @date 2024-07-12
 */

@Getter
public enum DataDeletedStatus {
    NO(0, "未删除"),
    YES(1, "已删除");
    private final int type;
    private final String description;

    DataDeletedStatus(int type, String description) {
        this.type = type;
        this.description = description;
    }

    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(int type) {
        for (DataDeletedStatus status : DataDeletedStatus.values()) {
            if (status.getType() == type) {
                return status.getDescription();
            }
        }
        throw new IllegalArgumentException("No status found for type: " + type);
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static int getTypeByDesc(String description) {
        for (DataDeletedStatus status : DataDeletedStatus.values()) {
            if (status.getDescription().equalsIgnoreCase(description)) {
                return status.getType();
            }
        }
        throw new IllegalArgumentException("No status found for description: " + description);
    }
}
